import {apiGet,apiPost,apiUpload} from './apiCommon'
export  default{
  state: {
  /*  yearPayCost: {
      "year": "2016",//年份
      "totalCost": "797.22",//总费用
      "netPay": "979.89",//员工纯收入总额
      "netPayRate": "55.3",//纯收入总额占总费用的比例,不带%
      "employeeCost": "279.3",//员工支出总额
      "employeeCostRate": "89.3",//员工支出总额占总费用的比例,不带%
      "employerCost": "797.2",//公司抵扣项总额,"employerCostRate":"79.2",//公司抵扣项总额占总费用的比例,不带%
      "employerCostRate": "79.2",//公司抵扣项总额占总费用的比例,不带%
      "unit": "$",//纸币符合,1、$;2、RMB
    },*/
    scheduleList: [
      {
        'payScheduleId': '7974',
        'scheduleName': 'EveryMonth'
      },
      {
        'payScheduleId': '7973',
        'scheduleName': 'Every Other  Friday'
      },
      {
        'payScheduleId': '7979',
        'scheduleName': 'Every Other  Month'
      }
    ],
    selectDateList: null,
   /* payCheckList:null,
    payCheckListPb: null,*/
/*    schedulePeriod: {
      "scheduleName": "EveryMonth",
      "periodList": [
        {
          "periodStart": "2015/05/23",
          "periodEnd": "2016/02/05",
          "payDate": "2015/02/04",
          "isSelect": "1"//是否被选中--1、是；0、否
        },
        {
          "periodStart": "2015/05/23",
          "periodEnd": "2016/02/05",
          "payDate": "2015/02/04",
          "isSelect": "0"//是否被选中--1、是；0、否
        }
      ]
    },*/
   /* schedulePersonList: [
      {
        "personId": "7978",
        "personName": "test",
        "payRate": "46.56",
        "unit": "$",//纸币符号1、$;2、RMB
        "payRange": "hour",//hour,week,month,year
        "isRegularPay": "1",//1、可编辑；0、不可编辑
        "isOverTimePay": "1",
        "isDoubleOverTimePay": "1",
        "isSickPay": "1",
        "isVocationPay": "1",
        "isHolidayPay": "1",
        "isBonus": "1",
        "isCommision": "1"
      },
      {
        "personId": "7975",
        "personName": "test",
        "payRate": "46.56",
        "unit": "$",//纸币符号1、$;2、RMB
        "payRange": "hour",//hour,week,month,year
        "isRegularPay": "1",//1、可编辑；0、不可编辑
        "isOverTimePay": "1",
        "isDoubleOverTimePay": "1",
        "isSickPay": "1",
        "isVocationPay": "1",
        "isHolidayPay": "1",
        "isBonus": "1",
        "isCommision": "1"
      }
    ],
    schedulePersonListPb: {},
    schedulePersonListData: {},*/
    schedulePersonInitModel: {
      "personId": "",
      "regularH": "",//单位":小时
      "overTimeH": "",//单位":小时
      "doubleOverTimeH": "",//单位":小时
      "sickH": "",//单位":小时
      "vocationH": "",//单位":小时
      "holidayH": "",//单位":小时
      "bonusAmount": "",//单位":$
      "commisionAmount": "", //单位":$
      "grossyTotal": "2344",
      "unit": ""
    },
/*    //员工列表
    personList: [

    ],
    personListPb: {

    },*/
/*    personBasicInfo: {
      "personId": "7994",
      "employeeCode": "D7979",//这个值就是Employee ID
      "firstName": "Anne",
      "lastName": "Healthy",
      "headImg": "http://192.168.1.229/group1/M00/00/00/wKgB5VggOaSASpvuAADg3cJClNA686.png",
      "mi": "smith",
      "hireDate": "MM/dd/yyyy",
      "status": "Active",//Active,Terminated;Retired
      "gender": "Female",//Female;Male;None
      "birthDate": "MM/dd/yyyy",
      "workLocation": "2102 Fairway Drive San Francisco, CA94103",
      "homeAddress": "3875 Black Oak Road Monterey, CA 93940",
      "email": "Hathaway@gmail.com"
    },*/
/*    personPayInfo:{
      "unit":"$",//$;RMB
      "payRate":"56.45",
      "payRange":"hour",//hour,week,month,year
      "payScheduleName":"Every Friday",
      "payMethod":"Check",//Check;Deposit
      "taxes":"Married,with no allowances",
      "employeeDeduction":[//员工交的抵扣项
        {
        "deductionName":"401(K)",
        "amountType":"paycheck",//gross pay
        "amount":"$4646",
        "seperator":"/",
        "annualMax":"$4646"
        }
      ],
      "companyDeduction":[//公司交的抵扣项
        {
        "deductionName":"401(K)",
        "amountType":"paycheck",//gross pay
        "amount":"$4646",
        "seperator":"/",
        "annualMax":"$4646"
        },
        {
          "deductionName":"Medical",
          "amountType":"gross pay",//gross pay
          "amount":"2.00%",
          "seperator":"of",
        }
      ]
    },*/
    editPersonInfo: null,
    "personStatusList": [
      {
        "showName": "Active",
        "value": "1"
      },
      {
        "showName": "AAA",
        "value": "2"
      },
      {
        "showName": "BBB",
        "value": "3"
      }
    ],
    "personGenderList": [
      {
        "showName": "Female",
        "value": "1"
      }
    ],
    "personWorkLocationList": [
      {
        "showName": "Female",
        "value": "1"
      }
    ],
    "stateList": [
      {
        "showName": "FL",
        "value": "1"
      },
      {
        "showName": "ML",
        "value": "2"
      }
    ],
/*    addPersonInit:{
      "gender":[
        {
          "showName":"Female",
          "value":"1"
        }
      ],
      "w4FillStatus":[//联邦交税身份
        {
          "showName":"Single",
          "value":"1"
        },
        {
          "showName":"Married",
          "value":"2"
        },
        {
          "showName":"Married, but withhold at higher Single rate",
          "value":"3"
        },
        {
          "showName":"Do Not Withhold",
          "value":"4"
        }

      ],
      "state":[
        {
          "showName":"FL",
          "value":"FL",
        }
      ],
      "isStateTax":"true",//是否要上交州税,true:是；false:否
        "stateName" :"Minnesota" ,
        "stateFillStatus":[//州交税身份
        {
          "showName":"Female",
        "value":"1"
        }
      ]
    },*/
    //员工信息页激活的tab
    employeeInfoActiveTab:"personInfo",
/*   //添加Schedule的初始化数据
    addPayScheduleInit:{
      "personName":"Anne",
      "howOften":[
        {
          "showName":"Every Week",
          "value":"79797"
        },
        {
          "showName":"Every other Week",
          "value":"79796"
        }
      ]
    },*/
    addEmployeeDeductionInit:{
      "personName":"John",
      "deductionBigType":[
        {
          "showName":"garnishment",
          "value":"1"
        },
        {
          "showName":"deduction",
          "value":"2"
        }
      ],
      "deductionSmallType":[
        {
          "showName":"401(K)",
          "value":"1",
          "isEmployeeEnabled":"1",//1:可用;0:不可用
          "employeeAmountType":"1",
          "employeeAmount":"797.89",
          "employeeAnnualMax":"79879.69",
          "isEmployerEnabled":"1",//1:可用;0:不可用
          "employerAmountType":"1",
          "employerAmount":"797.89",
          "employerAnnualMax":"79879.69"
        }

      ],
      "garnishmentSmallType":[
        {
          "showName":"Federal Tax Levy",
          "value":"1"
        }

      ] ,
      "deductionAmountType":[
        {
          "showName":"$amount",
          "value":"1"     //1:’$amount’;2:’% of gross pay’
        }
      ]
    },
    personPayDetail:{
      "payScheduleName":"Every Other Saturday",//发薪策略名称
      "personName":"Jack",
      "homeAddress":"5726 Cortez Road W. #164 FL 0",
      "payPeriodStart":"MM/dd/yyyy",
      "payPeriodEnd":"MM/dd/yyyy",
      "payDate":"MM/dd/yyyy",
      "payFrom":"bankAccount"  ,
      "paidBy":"check",//check：支票；deposit:汇款
      "netPay":"464654",//纯收入
      "unit":"$",//纸币符号--$;RMB
      "pay":[
        {
        "type":"regularPay",
        "hour":"895",
        "rate":"88.9",
        "current":"7979",
        "ytd":"fadf"
        }
      ],
      "employeeTax":[
        {
          "type":"regularPay",
          "current":"7979",
          "ytd":"fadf"
        }
      ],
      "employeeDedu":[
        {
          "type":"regularPay",
          "current":"7979",
          "ytd":"88"
        }
      ],
      "employerTax":[
        {
          "type":"regularPay",
          "current":"7979",
          "ytd":"5785"
        }
      ],
      "employerDedu":[
        {
          "type":"regularPay",
          "current":"7979",
          "ytd":"555"
        }
      ]
    },
  //  editPayItem:null,
  //  addDeductionInit:null,
   // payPeriod:null,
    /*editPayInfo:null*/
  },
  mutations: {
    /*'setYearPayCost'(state,data) {
      state.yearPayCost = data;
    },*/
    'setPayCheckSelectDate'(state,data) {
      state.selectDateList = data.data.selectDate;
    },
 /*   'setScheduleList'(state,data){
      state.scheduleList = data.data.scheduleList;
    },*/
    /*'setPayCheckList'(state,data){
      state.payCheckList = data;
    },
    'setPayCheckListPb'(state,data){
      state.payCheckListPb = data;
    },*/
 /*   'setSchedulePeriod'(state,data){
      state.schedulePeriod = data.data;
    },*/
  /*  'setSchedulePersonList'(state,data){
      state.schedulePersonList = data;
    },
    'setSchedulePersonListPb'(state,data){
      state.schedulePersonListPb = data;
    },*/
    /*'setPersonList'(state,data){
      state.personList= data;
    },
    'setPersonListPb'(state,data){
      state.personListPb= data;
    },*/
   /* 'setPersonBasicInfo'(state,data){
      state.personBasicInfo= data;
    },*/
   /* 'setPersonPayInfo'(state,data){
      state.personPayInfo= data.data;
    },*/
  /*  setAddPersonInit(state,data){
      state.addPersonInit = data;
    },*/
    /**
    * 初始化SchedulePersonListData ,model用
    * */
/*    'initSchedulePersonListData'(state,data){
      if (!data || !data.length){
        return;
      }
      var obj={};
      for (var i=0;i<data.length;i++){
        if(state.schedulePersonListData&&state.schedulePersonListData[data[i].personId]){
          obj[data[i].personId] = state.schedulePersonListData[data[i].personId];
        }else{
          obj[data[i].personId] = state.schedulePersonInitModel;
          obj[data[i].personId].personId = data[i].personId;
        }
      }
      state.schedulePersonListData = JSON.parse(JSON.stringify(obj)) ;
    },*/
 /*   'setSchedulePersonListData'(state,data){
      var personData= JSON.parse(JSON.stringify(state.schedulePersonListData));
      personData[data.personId].grossyTotal = data.grossyTotal;
      personData[data.personId].unit = data.unit;
      state.schedulePersonListData = personData;
    },*/
    'setEditPersonInfo'(state,data){
      state.editPersonInfo = data;
    },
    'setPersonGenderList'(state,data){
      state.personGenderList = data;
    },
    'setPersonStatusList'(state,data){
      state.personStatusList = data;
    },
    'setPersonWorkLocationList'(state,data){
      state.personWorkLocationList = data || [];
    },
    'setStateList'(state,data){
      state.stateList = data;
    },
    'addWorkLocation'(state,data){
      state.personWorkLocationList.push({
        showName:data.data.workAddress,
        value:data.data.workLocationId
      })
    },
    //设置员工信息激活tab
    setEmployeeInfoActiveTab(state,tab){
      state.employeeInfoActiveTab = tab;
    },
  /*  setAddPayScheduleInit(state,data){
      state.addPayScheduleInit = data.data;
    },*/
  /*  setAddEmployeeDeductionInit(state,data){
      state.addEmployeeDeductionInit = data.data;
    },*/
    setPersonPayDetail(state,data){
      state.personPayDetail = data;
    },
   /* 'setEditPayItem'(state,data){
      state.editPayItem = data.data;
    },*/
 /*   setPayPeriod(state,data){
      state.payPeriod = data.data.payPeriod;
    },*/
/*    setEditPayInfo(state,data){
      state.editPayInfo = data.data
    }*/
  },
  actions: {
  /*  /!**
     统计公司年支出费用
     option.param={}
     * *!/
    getYearPayCost:({commit},option) =>{
      apiPost('/pay/getYearTotalCost',commit,option,function (data) {
        commit('setYearPayCost',data);
      });
    },*/
   /* /!**
    * 员工信息列表(url:personInfo/getPersonList.do)":
    * *!/
    getPersonList:({commit},option) =>{
      apiGet('/personInfo/getPersonList.do',commit,option,function (data) {
        commit('setPersonList',data.data.personInfo);
        commit('setPersonListPb',data.pb);
      });
    },*/
/*    /!**
    * 查询发薪日程列表(url:pay/queryPayScheduleList)
    * option.param={}
    * option.param={}
    * *!/
    getPayScheduleList:({commit},option) =>{
      apiPost('/pay/queryPayScheduleList',commit,option,function (data) {
        commit('setScheduleList',data);
      });
    },*/
    /**
      获取工资条时间查询条件
      option.param={}
    * */
    getPayCheckSelectDate:({commit},option) =>{
      apiPost('/pay/getPayCheckSelectDate',commit,option,function (data) {
        commit('setPayCheckSelectDate',data);
      });
    },
    /**
     获取工资条记录
    * option.param = {
       'startDate':'yyyy-MM-dd',
       'endDate':'yyyy-MM-dd'
       }
    * */
 /*   queryPayCheckList:({commit},option) =>{
      apiGet('/pay/queryPayCheckList',commit,option,function (data) {
        commit('setPayCheckList',data.data.payCheckList);
        commit('setPayCheckListPb',data.pb);
      });
    },*/
    /**
     查询发薪日程的周期列表
     option.param = {
     'scheduleId':'1245',
     }
    * */
   /* querySchedulePeriod:({commit},option) =>{
      apiGet('/pay/querySchedulePeriod',commit,option,function (data) {
        commit('setSchedulePeriod',data);
      });
    },*/
    /**
    * 查询与发薪日期相关的员工（url:pay/querySchedulePerson）
    *option.param={
    *   "scheduleId":"4468",
        "periodStart":"MM/dd/yyyy",
        "periodEnd":"MM/dd/yyyy"
      }
    * */
/*    querySchedulePerson:({commit},option) =>{
      apiGet('/pay/querySchedulePerson',commit,option,function (data) {
        commit('setSchedulePersonList',data.data.personList);
        commit('setSchedulePersonListPb',data.pb);
        commit('initSchedulePersonListData',data.data.personList);
      });
    },*/
    /**
    option.param={"personId":"4744", "regularH":"1",//单位":小时"overTimeH":"1",//单位":小时"doubleOverTimeH":"1",//单位":小时 "sickH":"1",//单位":小时"vocationH":"1",//单位":小时"holidayH":"1",//单位":小时"bonusAmount":"1",//单位":$"commisionAmount":"1" //单位":$}
    * 实时计算某个员工的工资总额(url:pay/caculateGrossyPay)-
    * */
   /* calculatePersonPay:({commit},option) =>{
      apiPost('/pay/caculateGrossyPay',commit,option,function (data) {
        commit('setSchedulePersonListData',data);
      });
    },*/
    uploadHeadImg:({commit},option) => {
      console.log(option.param)
      apiUpload('/personInfo/uploadHeadImg', commit, option, function (data) {
        //...
      });
    },
  /*  /!**
    * 获取员工的基础数据信息
     * option.param={personId:123}
    * *!/
    getPersonBasicInfo:({commit},option) => {
      apiGet('/personInfo/getPersonBasicInfo', commit, option, function (data) {
        commit('setPersonBasicInfo',data.data)
      });
    },*/
 /*   /!**
     * 获取员工的基础数据信息
     * option.param={personId:123}
     * *!/
    getAddPersonInit:({commit},option) => {
      apiGet('/personInfo/addPersonInit', commit, option, function (data) {
        commit('setAddPersonInit',data.data)
      });
    },*/
 /*   /!**
     * 获取员工的支付信息
     * option.param={personId:123}
     * *!/
    getPayInfo:({commit},option) => {
      apiGet('/pay/getPayInfo', commit, option, function (data) {
        commit('setPersonPayInfo',data)
      });
    },*/
/*    /!***
     * 获取员工的初始化的支付编辑数据'
     * @option.param={personId:123}
     * *!/
    initEditPayInfo:({commit},option) => {
      apiGet('/pay/editPayInfo', commit, option, function (data) {
        commit('setEditPayInfo',data);
      });
    },*/
   /* /!***
     * submit
     * @option.param
     * *!/
    savePayInfo:({commit},option) => {
      apiGet('/pay/savePayInfo', commit, option, function (data) {

      });
    },*/
   /* /!***
     * howOften init
     * *!/
    getAddPayScheduleInit:({commit},option) => {
      apiGet('/payschedule/addPayScheduleInit', commit, option, function (data) {
        commit('setAddPayScheduleInit',data)
      });
    },*/
   /* /!***
     * howOften submit
     * *!/
    addPaySchedule:({commit},option) => {
      apiGet('/payschedule/addPaySchedule', commit, option, function (data) {

      });
    },*/
   /* /!***
     * howMuch init
     * *!/
    initEditPayItem:({commit},option) => {
      apiGet('/pay/editPayItem', commit, option, function (data) {
        commit('setEditPayItem',data)
      });
    },*/
  /*  /!***
     * howMuch submit
     * *!/
    modifyPayItem:({commit},option) => {
      apiGet('/pay/modifyPayItem', commit, option, function (data) {

      });
    },*/
/***
     * 获取员工的初始化的编辑员工数据
     * @option.param={personId:123}
     * */
    getEditPersonInfo:({commit},option) => {
      apiGet('/personInfo/editPersonInfo', commit, option, function (data) {
        debugger
        commit('setEditPersonInfo',data.data.personInfo);
        commit('setPersonGenderList',data.data.gender);
        commit('setPersonStatusList',data.data.status);
        commit('setPersonWorkLocationList',data.data.workLocation);
        commit('setStateList',data.data.state);
      });
    },
    /***
     * 修改员工信息
     * */
    modifyPersonInfo:({commit},option) => {
      apiPost('/personInfo/modifyPersonInfo', commit, option, function (data) {
      });
    },
 /*   /!***
     * 添加员工
     * *!/
    addPerson:({commit},option) => {
      apiPost('/personInfo/addPerson', commit, option, function (data) {

      });
    },*/
    /***
     * 添加工作地址
     * */
    addWorkLocation:({commit},option) => {
      apiPost('/personInfo/addWorkLocation', commit, option, function (data) {
        commit('addWorkLocation',data)
      });
    },
 /*   /!***
     * 增加员工抵扣项初始化(url:/deduction/init)
     * @param.option = {personId:123}
     * *!/
    addEmployeeDeductionInit:({commit},option) => {
      apiGet('/deduction/init', commit, option, function (data) {
        commit('setAddEmployeeDeductionInit',data);
      });
    },*/
    deleteDeduction:({commit},option) => {
      apiGet('/deduction/remove', commit, option, function (data) {
      });
    },
 /*   /!***
     * 保存员工抵扣项(url: deduction/save)
     * @param.option = {personId:123}
     * *!/
    saveDeduction:({commit},option) => {
      apiGet('/deduction/save', commit, option, function (data) {

      });
    },*/
  /*  /!***
     * 查询发薪日程的发薪周期
     * @param.option
     * *!/
    getPayPeriod:({commit},option) => {
      apiGet('/payschedule/queryPayPeriod', commit, option, function (data) {
        commit('setPayPeriod',data);
      });
    }*/
  },
  getters: {
 /*   yearPayCost: (state, getters) => {
      return state.yearPayCost;
    },
    yearPayCostObj: (state, getters) => {
      if (state.yearPayCost) {
        let data = state.yearPayCost;
        return {
          payList: [
            {name: 'EMPLOYER', value: data.employerCost, rate: data.employerCostRate},
            {name: 'NET PAY', value: data.netPay, rate: data.netPayRate},
            {name: 'EMPLOYEE', value: data.employeeCost, rate: data.employeeCostRate},
          ],
          payUnit: data.unit,
          payYear: data.year,
          payTotal: data.totalCost
        }
      }
    },*/
 /*   personList: (state, getters)=> {
      return state.personList;
    },
    personListPb: (state, getters)=> {
      return state.personListPb;
    },*/
/*    scheduleList: (state, getters)=> {
      return state.scheduleList;
    },*/
    selectDateList: (state, getters)=> {
      return state.selectDateList;
    },
   /* payCheckList: (state, getters)=> {
      return state.payCheckList;
    },
    payCheckListPb: (state, getters)=> {
      return state.payCheckListPb;
    },*/
/*    schedulePeriod: (state, getters)=> {
     return state.schedulePeriod;
     },*/
/*    schedulePersonList: (state, getters)=> {
      return state.schedulePersonList;
    },
    schedulePersonListPb: (state, getters)=> {
      return state.schedulePersonListPb;
    },
    schedulePersonListData: (state, getters)=> {
      return state.schedulePersonListData;
    },*/
/*    personPayInfo:(state, getters)=> {
      return state.personPayInfo;
    },*/
/*    personBasicInfo:(state, getters)=> {
      return state.personBasicInfo;
    },*/
    editPersonInfo:(state,getters)=> {
      return state.editPersonInfo;
    },
    personGenderList:(state,getters)=> {
      return state.personGenderList;
    },
    personStatusList:(state,getters)=> {
      return state.personStatusList;
    },
    personWorkLocationList:(state,getters)=> {
      return state.personWorkLocationList;
    },
    stateList:(state,getters)=> {
      return state.stateList;
    },
/*    addPersonInit:(state,getters)=> {
      return state.addPersonInit;
    },*/
    employeeInfoActiveTab:(state,getters)=> {
      return state.employeeInfoActiveTab;
    },
/*    addPayScheduleInit:(state,getters)=> {
      return state.addPayScheduleInit;
    },*/
    addEmployeeDeductionInit:(state,getters)=> {
      return state.addEmployeeDeductionInit;
    },
    personPayDetail:(state,getters)=> {
      return state.personPayDetail;
    },
/*    editPayItem:(state,getters)=> {
      return state.editPayItem;
    },*/
  /*  payPeriod:(state,getters)=> {
      return state.payPeriod;
    },*/
/*    editPayInfo:(state,getters)=> {
      return state.editPayInfo;
    },*/

  }
}
